<include file="Public/head" />
<body>
<article class="page-container">
	<form class="form form-horizontal" action="{:U('articleAddAction')}" method="post" id="form-article-add">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>文章标题：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="" placeholder="" name="title">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>文章类型：</label>
			<div class="formControls col-xs-8 col-sm-9"> <span class="select-box">
				<select name="type_id" class="select">
					<option value="">全部分类</option>
					<volist name="cate" id="rs">
						<option value="{$key}">{$rs}</option>
					</volist>
				</select>
				</span>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">排序值：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="100" placeholder="" maxlength="8" name="sort">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">关键词：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="" maxlength="250" placeholder="" name="keywords">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">文章摘要：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<textarea name="abstract" maxlength="500" cols="" rows="" class="textarea"  placeholder="说点什么...最少输入10个字符" datatype="*10-100" dragonfly="true" nullmsg="备注不能为空！" onKeyUp="textarealength(this,200)"></textarea>
				<p class="textarea-numberbar"><em class="textarea-length">0</em>/200</p>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">文章作者：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="" placeholder="" id="" name="author" maxlength="50">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">缩略图：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<div class="uploader-thum-container">
					<div id="fileList" class="uploader-list"><img src="" alt="" class="" width="80px" height="80px"></div>
					<input id="fileadd" type="file" class="hidden" name="file" value="" onchange='ajaxFileUpload(this)'>
					<input type="hidden" name="thumb" value="">
					<button id="btn-star" class="btn btn-default btn-uploadstar radius ml-10" type="button">选择图片</button>
				</div>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">文章内容：</label>
			<div class="formControls col-xs-8 col-sm-9"> 
				<script id="editor" type="text/plain" style="width:100%;height:600px;" name="content"></script>
			</div>
		</div>
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
				<button onClick="article_save();" class="btn btn-secondary radius" type="button"><i class="Hui-iconfont">&#xe632;</i> 保存 </button>
				<button onClick="javascript:window.location.href='{:U('index')}'" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
			</div>
		</div>
	</form>
</article>

<include file="Public/js" />

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__PUBLIC__/lib/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="__PUBLIC__/lib/ueditor/1.4.3/ueditor.config.js"></script>
<script type="text/javascript" src="__PUBLIC__/lib/ueditor/1.4.3/ueditor.all.min.js"> </script>
<script type="text/javascript" src="__PUBLIC__/lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
<script type='text/javascript' src="__PUBLIC__/lib/ajaxfileupload.js"></script>
<script type="text/javascript">
$(function(){
	var ue = UE.getEditor('editor',{
		serverUrl :'{:U("Article/ueditor")}'
	});
	$('#btn-star').click(function(){
		$('#fileadd').click();
	});
});
function article_save(){
	$('form').submit();
}
function ajaxFileUpload(obj) {
	jQuery.ajaxFileUpload({
		url : "{:U('uploadThumb')}", //用于文件上传的服务器端请求地址
		secureuri : false, //是否需要安全协议，一般设置为false
		fileElementId : obj.id, //文件上传域的ID
		dataType : 'text', //返回值类型 一般设置为json
		success : function(data, status) {
			var dataObj = $.parseJSON( data );
			console.log(dataObj);
			if(dataObj.status == 1) {
				$('#fileList img').attr('src','__ROOT__/'+dataObj.file);
				$('input[name="thumb"]').val(dataObj.file);
			} else {
				layer.msg(dataObj.info,{icon:7});
			}
		}
	})
}
</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>